package cz.zcu.fav.rat.beans;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

public class Reservation implements Serializable, Indexable
{

	private static final long serialVersionUID = 1L;
	private User user;
	private Object object;
	private Set<Period> periods = new HashSet<Period>();
	private Integer id;

	public Object getObject()
	{
		return object;
	}

	public void setObject(Object object)
	{
		this.object = object;
	}

	public Integer getId()
	{
		return id;
	}

	public void setId(Integer id)
	{
		this.id = id;
	}

	public User getUser()
	{
		return user;
	}

	public void setUser(User user)
	{
		this.user = user;
	}

	public Set<Period> getPeriods()
	{
		return periods;
	}

	public void setPeriods(Set<Period> periods)
	{
		this.periods = periods;
	}

	public void addPeriod(Period period)
	{
		this.periods.add(period);
	}

	@Override
	public int hashCode()
	{
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((object == null) ? 0 : object.hashCode());
		return result;
	}

	@Override
	public boolean equals(java.lang.Object obj)
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Reservation other = (Reservation) obj;
		if (id == null)
		{
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (object == null)
		{
			if (other.object != null)
				return false;
		} else if (!object.equals(other.object))
			return false;
		return true;
	}
}
